package com.tools;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.bean.ZXData;
import com.bean.ZXfeeds;


public class ZhenXiangDiJson {
private ArrayList<ZXfeeds> zXfeeds;
public ArrayList<ZXfeeds> json(String respose){
	try {
		JSONObject object=new JSONObject(respose);
		JSONObject object2 = object.getJSONObject("paramz");
		JSONArray jsonArray = object2.getJSONArray("feeds");
		zXfeeds=new ArrayList<ZXfeeds>();
		for (int i = 0; i <jsonArray.length(); i++) {
			JSONObject feedsobj = jsonArray.getJSONObject(i);
			ZXfeeds feeds=new ZXfeeds();
			feeds.setCategory(feedsobj.getString("category"));
			feeds.setId(feedsobj.getString("id"));
			feeds.setOid(feedsobj.getString("oid"));
			JSONObject dataobj = feedsobj.getJSONObject("data");
			ZXData data=new ZXData();
			data.setChanged(dataobj.getString("changed"));
			data.setCover(dataobj.getString("cover"));
			data.setFormat(dataobj.getString("format"));
			data.setSubject(dataobj.getString("subject"));
			data.setTruth(dataobj.getString("truth"));
			feeds.setData(data);
			zXfeeds.add(feeds);
		}
	} catch (JSONException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return zXfeeds;
	
}
}
